\documentclass[t,12pt,aspectratio=169]{beamer} % 16:9 宽屏比例，适合现代投影
\usepackage{ctex} % 中文支持
\usepackage{amsmath, amssymb} % 数学公式与符号
\usepackage{graphicx}
\usepackage{pythonhighlight}
\usepackage{url}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 使表格美观
\usepackage{array}
\newcolumntype{M}[1]{>{\centering\arraybackslash}m{#1}}
%\newcolumntype{N}{@{}m{0pt}@{}}
\setlength\extrarowheight{3pt}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% 主题设置（推荐简洁风格）
\usetheme{Madrid}
\usecolortheme{default} % 可选：seahorse, beaver, dolphin 等

\title{Python使用入门 }
\author{SSK ET AL}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}

\begin{frame}
  \titlepage
\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}{目录 }

\begin{enumerate}
\item[2.1.]  Python概述 
\item[2.2.]  Python基本数据类型  
\item[2.3.]  函数  
\item[2.4.]  Numpy库  
\item[2.5.]  Pandas库
\item[2.6.]  文件操作  
\item[2.7.]  Scipy库  
\item[2.8.]  Sympy库  
\item[2.9.]  Matplotlib库  

\end{enumerate}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}{2.1.1. Python开发环境安装与配置 }

\begin{itemize}\itemsep0.5em 

\item  WinPython主页： \url{https://winpython.github.io}

%\item  WinPython = Python 3.11.4 64bit with PyQt5 + Spyder + Torch

\item WinPython下载：\url{https://sourceforge.net/projects/winpython/}

\item Anaconda主页：\url{https://www.anaconda.com}

\item 与 Matlab 很像的开发环境：Spyder. 

\item 能同时写文档与写程序的开发环境：Jupyter Notebook. 

\end{itemize}


\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}{2.1.1. Winpython 包含的常用库 }

{\footnotesize 
\begin{tabular}{|p{2.5cm}|p{6cm}|} \hline 
库名 & 说明 \\ \hline 
numpy+mkl & 科学计算和数据分析的基础库 \\ \hline 
scipy & numpy基础上的科学计算库 \\ \hline 
sympy & 符号计算库 \\ \hline 
pandas &numpy基础上的数据分析库  \\ \hline 
matplotlib & 数据可视化库 \\ \hline 
scikit-learn & 机器学习库  \\ \hline 
statsmodels & scipy统计函数的补充库 \\ \hline 
networkx & 图论和复杂网络库 \\ \hline 
cvxpy & 凸优化库 \\ \hline 
NLTK & 自然语言库 \\ \hline 
PIL & 数字图像处理库 \\ \hline 
\end{tabular}
}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}{2.1.2. Python核心工具库 }

\begin{itemize}\itemsep0.5em 

\item  numpy

\item  scipy

\item  matplotlib

\item  IPython

\item  sympy

\item  pandas

\end{itemize}


\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}{2.1.3. Python编程规范 }

\begin{itemize}\itemsep0.5em 

\item  严格使用缩进来体现代码的逻辑从属关系。

\item  每个import语句只导入一个模块。

\item  建议在每个类、每个函数、每段代码之间加空行。

\item  避免使用过长的语句。

\item  使用括号明确运算的隶属关系和顺序。

\item  对关键代码进行必要的注释。

\item  冒号和缩进配合使用表示层次关系。

\item  第一行语句前面不能有空格。

\end{itemize}


\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}{2.2.1. 数字  }

\begin{itemize}\itemsep0.5em 

\item  整型，转换函数：int(x)

\item  浮点型，转换函数：float(x)

\item  复数型，转换函数：complex(x, y)

\item  布尔型


\end{itemize}


\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile]{2.2.2. 字符串 }

\begin{itemize}\itemsep0.5em 

\item  例子2.1. 字符串操作举例：

\begin{python}
#程序文件ex2_1.py
str1 = "Hello World!"
print(str1)       #输出字符串
print(str1[0:-1]) #输出第一个到倒数第2个的所有字符
print(str1[-1])   #输出字符串的最后一个字符
print(str1[2:5])  #输出从第三个开始到第五个的字符
print(str1[2:])   #输出从第三个开始的所有字符
print(str1*2)     #输出字符串两次
\end{python}

\end{itemize}


\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile]{2.2.3. 列表  }

\begin{itemize}\itemsep0.5em 

\item  例子2.3. 列表操作举例：

\begin{python}
#程序文件ex2_3.py
L = ['abc', 12, 3.45, 'Python', 2.789]
print(L)     #输出完整列表
print(L[0])  #输出列表的第一个元素
L[0] = 'a'   #修改列表的第一个元素
L[1:3] = ['b', 'Hello']  #修改列表的第二、三元素
print(L)
L[2:4] = []  #删除列表的第三、四元素
print(L)
\end{python}

\end{itemize}


\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile]{2.2.4. 元组  }

\begin{itemize}\itemsep0.5em 

\item  例子2.6. 元组操作举例：

\begin{python}
#程序文件ex2_6.py
T = ('abc', 12, 3.45, 'Python', 2.789)
print(T)       #输出完整元组
print(T[-1])   #输出元组的最后一个元素
print(T[1:3])  #输出元组的第二、三元素
\end{python}

\end{itemize}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile]{2.2.5. 集合 }

\begin{itemize}\itemsep0.5em 

\item  例子2.7. 集合操作举例：

\begin{python}
#程序文件ex2_7.py
student = {'Tom', 'Jim', 'Mary', 'Tom', 'Jack', 'Rose'}
print(student)
a = set('abcdabc')
print(a)  #每次输出是不一样的，如输出：{'d', 'b', 'a', 'c'}
\end{python}


\end{itemize}


\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile]{2.2.6. 字典 }

\begin{itemize}\itemsep0.5em 

\item  例子2.8. 字典操作举例：

\begin{python}
#程序文件ex2_8.py
dict1 ={'Alice': '123', 'Beth': '456', 'Cecil': 'abc'}
print(dict1['Alice'])   #输出123
dict1['new'] = 'Hello'  #增加新的键值对
dict1['Alice'] = '1234' #修改已有键值对
dict2 = {'abc': 123, 456: 78.9}
print(dict2[456])       #输出78.9
\end{python}

\end{itemize}


\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile]{2.3.1. 自定义函数 }

\begin{itemize}\itemsep0.5em 

\item  例子2.12. 定义阶乘函数、输出斐波那契数列的函数：

\begin{python}
#程序文件ex2_12_1.py
def factorial(n):  #定义阶乘函数
    r = 1
    while n > 1:
        r *= n
        n -= 1
    return r
def fib(n):   #定义输出斐波那契数列函数
    a, b = 1, 1
    while a < n:
        print(a, end='  ')
        a, b = b, a+b

print('%d!=%d'%(5,factorial(5))); fib(200)
\end{python}


\end{itemize}


\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile]{2.3.2. 模块的导入与使用  }

\begin{itemize}\itemsep0.5em 

\item  例子2.15. 载入模块举例：

\begin{python}
#程序文件ex2_15.py
import math                  #导入标准库math
import random                #导入标准库random
import numpy.random as nr    #导入numpy库中的random模块
a=math.gcd(12,21)            #计算最大公约数，a=3
b=random.randint(0,2)        #获得[0,2]区间上的随机整数
c=nr.randint(0,2,(4,3))      #获得[0,2)区间上的4×3随机整数矩阵
print(a); print(b); print(c) #输出a,b,c的值
\end{python}

\end{itemize}


\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile]{2.3.3. Python常用内置函数用法  }

\begin{itemize}\itemsep0.5em 

\item  例子2.19. 内置函数使用举例：

\begin{python}
#程序文件ex2_19.py
import numpy.random as nr
x1=list(range(9,21))
nr.shuffle(x1)       #shuffle()用来随机打乱顺序
x2=sorted(x1)        #按照从小到大排序
x3=sorted(x1,reverse=True)  #按照从大到小排序
x4=sorted(x1,key=lambda item:len(str(item)))  #以指定的规则排序
print(x1); print(x2); print(x3); print(x4)
\end{python}

\end{itemize}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile]{2.4.1. Numpy的基本使用 }

\begin{itemize}\itemsep0.5em 

\item  例子2.25. 数组生成举例：

\begin{python}
#程序文件ex2_25.py
import numpy as np
a1 = np.array([1, 2, 3, 4])   #生成整型数组
a2 = a1.astype(float)
a3 = np.array([1, 2, 3, 4], dtype=float)   #浮点数
print(a1.dtype); print(a2.dtype); print(a3.dtype)
b = np.array([[1, 2, 3], [4, 5, 6]])
c = np.arange(1,5)        #生成数组[1, 2, 3, 4]
d = np.linspace(1, 4, 4)  #生成数组[1, 2, 3, 4]
e = np.logspace(1, 3, 3, base=2)  #生成数组[2, 4, 8]
\end{python}


\end{itemize}


\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile]{2.4.2. 矩阵的合并与分割 }

\begin{itemize}\itemsep0.5em 

\item  例子2.28. 矩阵合并举例：

\begin{python}
#程序文件ex2_28.py
import numpy as np
a = np.arange(16).reshape(4,4)  #生成4行4列的数组
b = np.floor(5*np.random.random((2, 4)))
c = np.ceil(6*np.random.random((4, 2)))
d = np.vstack([a, b])  #上下合并矩阵
e = np.hstack([a, c])  #左右合并矩阵
\end{python}


\end{itemize}


\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile]{2.4.3. 矩阵的简单运算 }

\begin{itemize}\itemsep0.5em 

\item  例子2.30. 矩阵元素求和举例：

\begin{python}
#程序文件ex2_30.py
import numpy as np
a = np.array([[0, 3, 4],
             [1, 6, 4]])
b = a.sum()   #使用方法，求矩阵所有元素的和
c1 = sum(a)   #使用内置函数，求矩阵逐列元素的和
c2 = np.sum(a, axis=0) #使用函数，求矩阵逐列元素的和
c3 = np.sum(a, axis=0, keepdims=True)   #逐列求和
print(c2.shape, c3.shape)  #c2是(3,)数组，c3是(1,3)数组
\end{python}

\end{itemize}


\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile]{2.4.4. 矩阵运算与线性代数 }

\begin{itemize}\itemsep0.5em 

\item  例子2.34. 求解线性方程组 
$$\left\{ \begin{array}{rcl}
3x+y &=& 9, \\
x+2y &=& 8. 
\end{array} \right.$$

\vspace{0.3cm}

\begin{python}
#程序文件ex2_34.py
import numpy as np
a = np.array([[3, 1], [1, 2]])
b = np.array([9, 8])
x1 = np.linalg.inv(a) @ b  #第一种解法
#上面语句中@表示矩阵乘法
x2 = np.linalg.solve(a, b) #第二种解法
print(x1); print(x2)
\end{python}


\end{itemize}


\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile]{2.5.1. Pandas基本操作 }

\begin{itemize}\itemsep0.5em 

\item  例子2.38. 数据写入文件举例：


\begin{python}
#程序文件ex2_38_1.py
import pandas as pd
import numpy as np
dates=pd.date_range(start='20191101', end='20191124', freq='D')
a1=pd.DataFrame(np.random.randn(24,4), index=dates, columns=list('ABCD'))
a2=pd.DataFrame(np.random.randn(24,4))
a1.to_excel('data2_38_1.xlsx')
a2.to_csv('data2_38_2.csv')
f=pd.ExcelWriter('data2_38_3.xlsx')  #创建文件对象
a1.to_excel(f,"Sheet1")  #把a1写入Excel文件
a2.to_excel(f,"Sheet2")  #把a2写入另一个表单中
f.save()
\end{python}


\end{itemize}


\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile]{2.5.2. 数据的一些预处理 }

\begin{itemize}\itemsep0.5em 

\item  例子2.40. DataFrame数据的拆分、合并、分组计算：

\begin{python}
#程序文件ex2_40.py
import pandas as pd
import numpy as np
d=pd.DataFrame(np.random.randint(1,6,(10,4)), columns=list("ABCD"))
d1=d[:4]  #获取前4行数据
d2=d[4:]  #获取第5行以后的数据
dd=pd.concat([d1,d2])   #数据行合并
s1=d.groupby('A').mean()      #数据分组求均值
s2=d.groupby('A').apply(sum)  #数据分组求和
\end{python}


\end{itemize}


\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}{2.6.1. 文件操作基本知识 }

\begin{itemize}\itemsep0.5em 

\item  文件对象常用方法

\vspace{0.3cm}

{\footnotesize 
%\begin{table}
\begin{tabular}{|p{2.5cm}|p{8cm}|} \hline 
函数 & 说明 \\ \hline 
open() & 打开指定文件，并创建文件对象 \\ \hline 
close() & 把缓冲区内容写入文件，并关闭文件 \\ \hline 
read() & 从文本文件读取若干个字符 \\ \hline 
readline() & 从文本文件读入一行内容 \\ \hline 
readlines() &把文本文件的每行文本作为一个字符串存入列表 \\ \hline 
seek() & 把文件指针移动到指定位置 \\ \hline 
tell() & 返回文件指针当前位置 \\ \hline 
write(s) & 把字符串写入文件 \\ \hline 
writelines(s) & 把字符串列表写入文本文件 \\ \hline 
\end{tabular}
%\end{table}
}

\end{itemize}


\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile]{2.6.2. 文本文件操作 }

\begin{itemize}\itemsep0.5em 

\item  例子2.43. 随机产生一个数据矩阵，以逗号或空格作为分隔符，存入文本文件，再从文本文件读入数据：

\begin{python}
#程序文件ex2_43.py
import numpy as np
a=np.random.rand(6,8)  #生成6×8的[0,1)上均匀分布的随机数矩阵
np.savetxt("data2_43_1.txt", a)  #存成以制表符分隔的文本文件
np.savetxt("data2_43_2.csv", a, delimiter=',')  #存成以逗号分隔的文本文件
b=np.loadtxt("data2_43_1.txt")   #加载空格分隔的文本文件
c=np.loadtxt("data2_43_2.csv", delimiter=',')  #加载csv文件
\end{python}


\end{itemize}


\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}{2.7.1. Scipy简介 }

\begin{itemize}\itemsep0.5em 

\item   Scipy 的部分模块与功能

\vspace{0.3cm}

{\footnotesize 
%\begin{table}
\begin{tabular}{|p{4cm}|p{4cm}|} \hline 
模块 & 说明 \\ \hline 
scipy.cluster & 聚类分析等 \\ \hline 
scipy.integrate & 积分 \\ \hline 
scipy.interpolate & 插值 \\ \hline 
scipy.linalg & 线性代数 \\ \hline 
scipy.optimize & 优化 \\ \hline 
scipy.stats & 统计  \\ \hline 
scipy.fftpack & 傅立叶变换 \\ \hline 
%$\vdots$ & $\vdots$ \\ \hline 
\end{tabular}
%\end{table}
}

\end{itemize}


\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile]{2.7.2. Scipy基本操作 }

\begin{itemize}\itemsep0.5em 

\item  例子2.45. 求方程组的数值解：
$\left\{ \begin{array}{rcl}
x_1^2 + x_2^2 &=& 1, \\
x_1 - x_2 &=& 0. 
\end{array} \right.$

\vspace{0.3cm}

\begin{python}
#程序文件ex2_45.py
from scipy.optimize import fsolve, root
fx = lambda x: [x[0]**2+x[1]**2-1, x[0]-x[1]]
s1 = fsolve(fx, [1, 1])
s2 = root(fx, [1, 1])
print(s1,'\n','--------------'); print(s2)
\end{python}


\end{itemize}


\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile]{2.8. Sympy库  }

\begin{itemize}\itemsep0.5em 

\item  例子2.49. 求符号代数方程 $ax^2+bx+c=0$ 的解，其中 $x$ 为未知数：

\vspace{0.3cm}

\begin{python}
#程序文件ex2_49.py
import sympy as sp
a, b, c, x=sp.symbols('a,b,c,x')
x0=sp.solve(a*x**2+b*x+c, x)
print(x0)
\end{python}


\end{itemize}


\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile]{2.9.1. 二维绘图 }

\begin{itemize}\itemsep0.5em 

\item  例子2.52. 画出钻石和铂金的销售数据：

\begin{python}
#程序文件ex2_52.py
import pandas as pd
import pylab as plt
plt.rc('font',family='SimHei')  #用来正常显示中文标签
plt.rc('font',size=16)  #设置显示字体大小
a=pd.read_excel("data2_52.xlsx", header=None)
b=a.values  #提取其中的数据
x=b[0]; y=b[1:]
plt.plot(x,y[0],'-*b',label='铂金')
plt.plot(x,y[1],'--dr',label='铂金')
plt.xlabel('月份'); plt.ylabel('每月销量')
plt.legend(loc='upper left'); plt.grid(); plt.show()
\end{python}


\end{itemize}


\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}{2.9.1.  }

%\begin{center}
\begin{figure}
\includegraphics[height=0.6\textheight, width=0.6\textwidth]{ex-2-52.png}
\end{figure}
%\end{center}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile]{2.9.2. 三维绘图 }

\begin{itemize}\itemsep0.5em 

\item  例子2.55. 画出三维曲线的图形：
$$\left\{ \begin{array}{rcl}
x &=& s^2\sin s, \\
y &=& s^2\cos s, \\ 
z &=& s,
\end{array} \right.
s\in [-50,50] $$

\vspace{0.3cm}

\begin{python}
#程序文件ex2_55.py
import pylab as plt
import numpy as np
ax=plt.axes(projection='3d')  #设置三维图形模式
z=np.linspace(-50, 50, 1000)
x=z**2*np.sin(z); y=z**2*np.cos(z)
plt.plot(x, y, z, 'k'); plt.show()
\end{python}

\end{itemize}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}{2.9.2.  }

%\begin{center}
\begin{figure}
\includegraphics[height=0.6\textheight, width=0.8\textwidth]{ex-2-55.png}
\end{figure}
%\end{center}

\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}{参考文献  }

\begin{thebibliography}{1}

\bibitem{sishoukui-2} 司守奎,孙玺菁. {Python数学建模算法与应用}, 国防工业出版社. 2022年1月第1版. 


\end{thebibliography}


\end{frame}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\end{document}


